import time
from selenium import webdriver
import time

# 实例化浏览器对象
driver=webdriver.Chrome()
# 隐式等待
driver.implicitly_wait(10)
# 发送访问Agileone首页的请求
driver.get("http://localhost/agileone/")
# 断言
assert driver.find_element_by_id("login")
# 登录
driver.find_element_by_id("username").send_keys("admin")
driver.find_element_by_id("password").send_keys("admin")
driver.find_element_by_id("login").click()
time.sleep(3)
# assert driver.find_element_by_partial_link_text("公告管理")      断言1
expect_login= "下午好"                 # 断言2
actual_login=driver.find_element_by_id("welcome").text
if expect_login in actual_login:
    print("login succeed.")
else:
    print("login failed.")
# assert expect_login in actual_login       断言3
driver.minimize_window()          #最小化窗口
time.sleep(3)
driver.maximize_window()          #最大化窗口
time.sleep(3)
driver.set_window_size(700,300)   #自定义窗口
time.sleep(3)
driver.back()          # 后退
time.sleep(3)
driver.forward()       # 前进
# time.sleep(3)
# driver.quit()       # 关闭所有窗口
time.sleep(3)
driver.close()       # 关闭当前窗口




